package com.jk.bglog.service;

import com.jk.bglog.dao.AdminDao;
import com.jk.bglog.entity.AdministratorEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.stereotype.Service;
import org.springframework.data.mongodb.core.query.Query;

import javax.annotation.Resource;
import java.util.List;

@Service
public class AdminService {
    @Resource
    private AdminDao AdminDao;
    @Autowired
    private MongoTemplate MongoTemplate;

    /**
     * @description:  查询管理员列表
     * @param: [administratorEntity]
     * @return: java.util.List<com.jk.bglog.entity.AdministratorEntity>
     * @author 刘杨彬
     * @date: 2021/9/1 21:18
     */
    public List<AdministratorEntity> findAdministrator(AdministratorEntity administratorEntity) {
        Query query = new Query();
        if (administratorEntity.getWardenOperate()!= null && administratorEntity.getWardenOperate() != ""){
            query.addCriteria(Criteria.where("wardenOperate").regex(administratorEntity.getWardenOperate()));

        }
        List<AdministratorEntity> list = MongoTemplate.find(query, AdministratorEntity.class);

        return list;
    }
}
